/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package radiostationv41;

import javax.swing.JFrame;
import javax.swing.JOptionPane;


/**
 *
 * @author Stella
 */
public class ArtistFrame extends javax.swing.JFrame {
    JFrame parentFrame;
    
    
  public ArtistFrame(JFrame parentFrame) {
    initComponents();
    this.parentFrame=parentFrame;
    this.parentFrame.setEnabled(false); 
   
        
    }

   

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        RadioStationV41PUEntityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("RadioStationV41PU").createEntityManager();
        artistQuery1 = java.beans.Beans.isDesignTime() ? null : RadioStationV41PUEntityManager.createQuery("SELECT a FROM Artist a");
        artistList1 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : artistQuery1.getResultList();
        artistQuery2 = java.beans.Beans.isDesignTime() ? null : RadioStationV41PUEntityManager.createQuery("SELECT a FROM Artist a");
        artistQuery = java.beans.Beans.isDesignTime() ? null : RadioStationV41PUEntityManager.createQuery("SELECT a FROM Artist a");
        artistList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : artistQuery.getResultList();
        jPanel1 = new javax.swing.JPanel();
        NewButton1 = new javax.swing.JButton();
        EditButton2 = new javax.swing.JButton();
        DeleteButton3 = new javax.swing.JButton();
        ExitButton4 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Αρχείο Καλλιτεχνών", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Calibri", 1, 18))); // NOI18N

        NewButton1.setText("Νέο");
        NewButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NewButton1ActionPerformed(evt);
            }
        });

        EditButton2.setText("Επεξεργασία");

        DeleteButton3.setText("Διαγραφή");
        DeleteButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DeleteButton3ActionPerformed(evt);
            }
        });

        ExitButton4.setText("Έξοδος");
        ExitButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ExitButton4ActionPerformed(evt);
            }
        });

        jTable1.setColumnSelectionAllowed(true);

        org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, artistList, jTable1);
        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${artistLastName}"));
        columnBinding.setColumnName("Artist Last Name");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${artistFirstName}"));
        columnBinding.setColumnName("Artist First Name");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${musicGenreName}"));
        columnBinding.setColumnName("Music Genre Name");
        columnBinding.setColumnClass(radiostationv41.MusicGenre.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${artistBirthPlace}"));
        columnBinding.setColumnName("Artist Birth Place");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${artistBirthDay}"));
        columnBinding.setColumnName("Artist Birth Day");
        columnBinding.setColumnClass(java.util.Date.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${artistSex}"));
        columnBinding.setColumnName("Artist Sex");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${artistArtisticName}"));
        columnBinding.setColumnName("Artist Artistic Name");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        bindingGroup.addBinding(jTableBinding);
        jTableBinding.bind();
        jScrollPane1.setViewportView(jTable1);
        jTable1.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(NewButton1)
                        .addGap(66, 66, 66)
                        .addComponent(EditButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(76, 76, 76)
                        .addComponent(DeleteButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(85, 85, 85)
                        .addComponent(ExitButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 452, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(61, Short.MAX_VALUE))
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {DeleteButton3, ExitButton4, NewButton1});

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(50, 50, 50)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(NewButton1)
                    .addComponent(EditButton2)
                    .addComponent(DeleteButton3)
                    .addComponent(ExitButton4))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void DeleteButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DeleteButton3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_DeleteButton3ActionPerformed

    private void ExitButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ExitButton4ActionPerformed
        parentFrame.setEnabled(true);
        dispose();
    }//GEN-LAST:event_ExitButton4ActionPerformed

    private void NewButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NewButton1ActionPerformed
       ArtistFormFrame aff =new ArtistFormFrame(this, 1 , null);
       aff.setTitle("Καλλιτέχνες");
       aff.setLocation(320,100);
       aff.setVisible(true);
    }//GEN-LAST:event_NewButton1ActionPerformed

    /**
     * @param args the command line arguments
     */
  
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton DeleteButton3;
    private javax.swing.JButton EditButton2;
    private javax.swing.JButton ExitButton4;
    private javax.swing.JButton NewButton1;
    private javax.persistence.EntityManager RadioStationV41PUEntityManager;
    private java.util.List<radiostationv41.Artist> artistList;
    private java.util.List<radiostationv41.Artist> artistList1;
    private javax.persistence.Query artistQuery;
    private javax.persistence.Query artistQuery1;
    private javax.persistence.Query artistQuery2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables
}
